package com.baihang.project.ds.controller;

import java.io.IOException;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.socket.TextMessage;

import com.baihang.project.ds.webSocket.DsWebSocketHandler;

@Controller
@RequestMapping("/websocket")
public class WebSocketController {
	
	@RequestMapping("/index")
	public String index() {
		
		return "/project/ds/websocket/index";
	}
	@ResponseBody
	@RequestMapping("/sendMsg")
	public void sendMsg() {
		try {
			DsWebSocketHandler.mysession.sendMessage(new TextMessage("收到服务端消息"));
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
